package com.iot.controller;

import com.iot.model.query.ElectronicFenceRecordQuery;
import com.iot.model.query.FollowQuery;
import com.iot.model.dto.FollowDto;
import com.iot.service.ElectronicFenceRecordService;
import com.iot.service.FollowService;
import com.iot.commons.ResponseResult;
import com.iot.utils.ResponseResultUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 
 * @author: dh
 * @date: 2024-04-22 17:25:47
 */
@RestController
@RequestMapping("/follow")
@RequiredArgsConstructor
public class FollowController {

    private final FollowService followService;

    private final ElectronicFenceRecordService electronicFenceRecordService;

    /**
     * 分页条件搜索实现
     * @param follow
     * @return resultList
     */
    @PostMapping(value = "/getList")
    public ResponseResult getList(@RequestBody FollowQuery follow) {
        return  followService.getList(follow);
    }

    /**
     * 修改
     * @param follow
     * @return
     */
    @PostMapping(value = "/edit")
    public ResponseResult edit(@RequestBody FollowDto follow) {
        return followService.edit(follow);
    }

    /**
     * 关联电子围栏
     * @param follow
     * @return
     */
    @PostMapping(value = "/bindElectronicFence")
    public ResponseResult bindElectronicFence(@RequestBody FollowDto follow) {
        return followService.bindElectronicFence(follow);
    }

    /**
     * 取消关联
     * @param follow
     * @return
     */
    @PostMapping(value = "/unBindElectronicFence")
    public ResponseResult unBindElectronicFence(@RequestBody FollowDto follow) {
        return followService.unBindElectronicFence(follow);
    }


    /**
     * 取消关注
     * @param follow
     * @return
     */
    @PostMapping(value = "/cancel")
    public ResponseResult cancel(@RequestBody FollowDto follow) {
        return followService.cancel(follow);
    }

    /**
     * 新增
     * @param follow
     * @return
     */
    @PostMapping(value = "/add")
    public ResponseResult add(@RequestBody FollowDto follow) {
        return ResponseResultUtil.success(followService.add(follow));
    }

    /**
     * 详情
     * @param follow
     * @return
     */
    @PostMapping(value = "/getById")
    public ResponseResult getById(@RequestBody FollowQuery follow) {
        return followService.getById(follow);
    }

    /**
     * 获取步数数据
     * @param follow
     * @return
     */
    @PostMapping(value = "/getStepData")
    public ResponseResult getStepData(@RequestBody FollowQuery follow) {
        return followService.getStepData(follow);
    }

    /**
     * 获取血压数据
     * @param follow
     * @return
     */
    @PostMapping(value = "/getBpData")
    public ResponseResult getBpData(@RequestBody FollowQuery follow) {
        return followService.getBpData(follow);
    }

    /**
     *
     * 获取定位数据
     * @param follow
     * @return
     */
    @PostMapping(value = "/getLocationData")
    public ResponseResult getLocationData(@RequestBody FollowQuery follow) {
        return followService.getLocationData(follow);
    }

    /**
     * 获取预计列表
     * @param query
     * @return
     */
    @PostMapping(value = "/getFenceTriggerRecord")
    public ResponseResult getElectronicFence(@RequestBody ElectronicFenceRecordQuery query) {
        return electronicFenceRecordService.getList(query);
    }

    /**
     * 分页条件搜索实现
     * @param follow
     * @return resultList
     */
    @PostMapping(value = "/send")
    public ResponseResult send(@RequestBody FollowQuery follow) {
       return followService.send(follow);
    }
}
